/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package system.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import system.GeneratorModel;
import system.OCL;
import system.Platform;
import system.Service;
import system.SystemPackage;
import system.Type;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>System</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link system.impl.SystemImpl#getTypes <em>Types</em>}</li>
 *   <li>{@link system.impl.SystemImpl#getServices <em>Services</em>}</li>
 *   <li>{@link system.impl.SystemImpl#getSubSystem <em>Sub System</em>}</li>
 *   <li>{@link system.impl.SystemImpl#getPackageName <em>Package Name</em>}</li>
 *   <li>{@link system.impl.SystemImpl#getConstraints <em>Constraints</em>}</li>
 *   <li>{@link system.impl.SystemImpl#getTargetPlatform <em>Target Platform</em>}</li>
 *   <li>{@link system.impl.SystemImpl#getGeneratorModels <em>Generator Models</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SystemImpl extends NamedClassImpl implements system.System {
	/**
	 * The cached value of the '{@link #getTypes() <em>Types</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypes()
	 * @generated
	 * @ordered
	 */
	protected EList<Type> types;

	/**
	 * The cached value of the '{@link #getServices() <em>Services</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getServices()
	 * @generated
	 * @ordered
	 */
	protected EList<Service> services;

	/**
	 * The cached value of the '{@link #getSubSystem() <em>Sub System</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubSystem()
	 * @generated
	 * @ordered
	 */
	protected EList<system.System> subSystem;

	/**
	 * The default value of the '{@link #getPackageName() <em>Package Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPackageName()
	 * @generated
	 * @ordered
	 */
	protected static final String PACKAGE_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPackageName() <em>Package Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPackageName()
	 * @generated
	 * @ordered
	 */
	protected String packageName = PACKAGE_NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getConstraints() <em>Constraints</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConstraints()
	 * @generated
	 * @ordered
	 */
	protected EList<OCL> constraints;

	/**
	 * The default value of the '{@link #getTargetPlatform() <em>Target Platform</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTargetPlatform()
	 * @generated
	 * @ordered
	 */
	protected static final Platform TARGET_PLATFORM_EDEFAULT = Platform.OS_GI;

	/**
	 * The cached value of the '{@link #getTargetPlatform() <em>Target Platform</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTargetPlatform()
	 * @generated
	 * @ordered
	 */
	protected Platform targetPlatform = TARGET_PLATFORM_EDEFAULT;

	/**
	 * The cached value of the '{@link #getGeneratorModels() <em>Generator Models</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGeneratorModels()
	 * @generated
	 * @ordered
	 */
	protected EList<GeneratorModel> generatorModels;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SystemImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SystemPackage.Literals.SYSTEM;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Type> getTypes() {
		if (types == null) {
			types = new EObjectContainmentEList<Type>(Type.class, this, SystemPackage.SYSTEM__TYPES);
		}
		return types;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Service> getServices() {
		if (services == null) {
			services = new EObjectContainmentEList<Service>(Service.class, this, SystemPackage.SYSTEM__SERVICES);
		}
		return services;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<system.System> getSubSystem() {
		if (subSystem == null) {
			subSystem = new EObjectContainmentEList<system.System>(system.System.class, this, SystemPackage.SYSTEM__SUB_SYSTEM);
		}
		return subSystem;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getPackageName() {
		return packageName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPackageName(String newPackageName) {
		String oldPackageName = packageName;
		packageName = newPackageName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SystemPackage.SYSTEM__PACKAGE_NAME, oldPackageName, packageName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OCL> getConstraints() {
		if (constraints == null) {
			constraints = new EObjectContainmentEList<OCL>(OCL.class, this, SystemPackage.SYSTEM__CONSTRAINTS);
		}
		return constraints;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Platform getTargetPlatform() {
		return targetPlatform;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTargetPlatform(Platform newTargetPlatform) {
		Platform oldTargetPlatform = targetPlatform;
		targetPlatform = newTargetPlatform == null ? TARGET_PLATFORM_EDEFAULT : newTargetPlatform;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, SystemPackage.SYSTEM__TARGET_PLATFORM, oldTargetPlatform, targetPlatform));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<GeneratorModel> getGeneratorModels() {
		if (generatorModels == null) {
			generatorModels = new EObjectContainmentEList<GeneratorModel>(GeneratorModel.class, this, SystemPackage.SYSTEM__GENERATOR_MODELS);
		}
		return generatorModels;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SystemPackage.SYSTEM__TYPES:
				return ((InternalEList<?>)getTypes()).basicRemove(otherEnd, msgs);
			case SystemPackage.SYSTEM__SERVICES:
				return ((InternalEList<?>)getServices()).basicRemove(otherEnd, msgs);
			case SystemPackage.SYSTEM__SUB_SYSTEM:
				return ((InternalEList<?>)getSubSystem()).basicRemove(otherEnd, msgs);
			case SystemPackage.SYSTEM__CONSTRAINTS:
				return ((InternalEList<?>)getConstraints()).basicRemove(otherEnd, msgs);
			case SystemPackage.SYSTEM__GENERATOR_MODELS:
				return ((InternalEList<?>)getGeneratorModels()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SystemPackage.SYSTEM__TYPES:
				return getTypes();
			case SystemPackage.SYSTEM__SERVICES:
				return getServices();
			case SystemPackage.SYSTEM__SUB_SYSTEM:
				return getSubSystem();
			case SystemPackage.SYSTEM__PACKAGE_NAME:
				return getPackageName();
			case SystemPackage.SYSTEM__CONSTRAINTS:
				return getConstraints();
			case SystemPackage.SYSTEM__TARGET_PLATFORM:
				return getTargetPlatform();
			case SystemPackage.SYSTEM__GENERATOR_MODELS:
				return getGeneratorModels();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SystemPackage.SYSTEM__TYPES:
				getTypes().clear();
				getTypes().addAll((Collection<? extends Type>)newValue);
				return;
			case SystemPackage.SYSTEM__SERVICES:
				getServices().clear();
				getServices().addAll((Collection<? extends Service>)newValue);
				return;
			case SystemPackage.SYSTEM__SUB_SYSTEM:
				getSubSystem().clear();
				getSubSystem().addAll((Collection<? extends system.System>)newValue);
				return;
			case SystemPackage.SYSTEM__PACKAGE_NAME:
				setPackageName((String)newValue);
				return;
			case SystemPackage.SYSTEM__CONSTRAINTS:
				getConstraints().clear();
				getConstraints().addAll((Collection<? extends OCL>)newValue);
				return;
			case SystemPackage.SYSTEM__TARGET_PLATFORM:
				setTargetPlatform((Platform)newValue);
				return;
			case SystemPackage.SYSTEM__GENERATOR_MODELS:
				getGeneratorModels().clear();
				getGeneratorModels().addAll((Collection<? extends GeneratorModel>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SystemPackage.SYSTEM__TYPES:
				getTypes().clear();
				return;
			case SystemPackage.SYSTEM__SERVICES:
				getServices().clear();
				return;
			case SystemPackage.SYSTEM__SUB_SYSTEM:
				getSubSystem().clear();
				return;
			case SystemPackage.SYSTEM__PACKAGE_NAME:
				setPackageName(PACKAGE_NAME_EDEFAULT);
				return;
			case SystemPackage.SYSTEM__CONSTRAINTS:
				getConstraints().clear();
				return;
			case SystemPackage.SYSTEM__TARGET_PLATFORM:
				setTargetPlatform(TARGET_PLATFORM_EDEFAULT);
				return;
			case SystemPackage.SYSTEM__GENERATOR_MODELS:
				getGeneratorModels().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SystemPackage.SYSTEM__TYPES:
				return types != null && !types.isEmpty();
			case SystemPackage.SYSTEM__SERVICES:
				return services != null && !services.isEmpty();
			case SystemPackage.SYSTEM__SUB_SYSTEM:
				return subSystem != null && !subSystem.isEmpty();
			case SystemPackage.SYSTEM__PACKAGE_NAME:
				return PACKAGE_NAME_EDEFAULT == null ? packageName != null : !PACKAGE_NAME_EDEFAULT.equals(packageName);
			case SystemPackage.SYSTEM__CONSTRAINTS:
				return constraints != null && !constraints.isEmpty();
			case SystemPackage.SYSTEM__TARGET_PLATFORM:
				return targetPlatform != TARGET_PLATFORM_EDEFAULT;
			case SystemPackage.SYSTEM__GENERATOR_MODELS:
				return generatorModels != null && !generatorModels.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (packageName: ");
		result.append(packageName);
		result.append(", targetPlatform: ");
		result.append(targetPlatform);
		result.append(')');
		return result.toString();
	}

} //SystemImpl
